#include<iostream>
#include<string>
unsigned long long num=0;
using namespace std;
int main(){
	string str;
	cin>>str;
	for(int i=0;i<str.length();i++)
		if(str[i]<'A')num=num*16+str[i]-'0';
		else num=num*16+str[i]-55;
	cout<<num;
	return 0;
}
